var Rotation = 0.0;

main();

function main() {
    const canvas = document.querySelector('#canvas10');
    const gl = canvas.getContext('webgl');

    if (!gl) {
        alert('加载失败，请更换浏览器');
        return;
    }

    const nshaderProgramInfo = createNormalShaderProgramInfo(gl);
    const eshaderProgramInfo = createEshadowProgramInfo(gl);

    const cube_buffer = Cube_bufferInit(gl, 1.4);
    const ball_buffer = Ball_bufferInit(gl, 1, 5, 2);

    var then = 0;

    function render(now) {
        var packedInfos = [];

        const cubeLocation = [0.5, 1.0, -11.0];
        const ballLocation = [-0.5, 1.0, -8.0];

        cube_modelmatrixInfo = {
            translateAttri: cubeLocation,
            rotateSpeed: [0, 0, 0],
        };

        const cube_matrix = createModelViewMatrix(cube_modelmatrixInfo);

        const cube_packedInfo = packInfo(cube_buffer, cube_matrix, nshaderProgramInfo);
        packedInfos.push(cube_packedInfo);
        //////////

        ball_modelmatrixInfo = {
            translateAttri: ballLocation,
            rotateSpeed: [0.7, 0.8, 1.0],
            transAfterRot: [0.0, 0.3, 0.0],
        };
        const ball_matrix = createModelViewMatrix(ball_modelmatrixInfo);

        const ball_packedInfo = packInfo(ball_buffer, ball_matrix, nshaderProgramInfo);
        const balleshade_packedInfo = packInfo(ball_buffer, ball_matrix, eshaderProgramInfo);
        packedInfos.push(balleshade_packedInfo);
        packedInfos.push(ball_packedInfo);
        //////////

        now *= 0.001;
        const deltaTime = now - then;
        then = now;

        drawScene(gl, packedInfos, deltaTime);

        requestAnimationFrame(render);
    }

    requestAnimationFrame(render);
}